package utils 
{
	/**
	 * ...
	 * @author Dmitriy Gaiduk
	 */
	public class Converter 
	{
		
		public static function getNumberFromStr(numStr:String, defaultNum:Number, errorReport:String, 
											defaultWithZeroLength:Boolean = false):Number
		{
			if ((numStr.length == 0) && (defaultWithZeroLength))
			{
				return defaultNum;
			}
			var num:Number = Number(numStr);
			if (isNaN(num))
			{
				ErrorsCollector.getInstance().collectError(errorReport);
				num = defaultNum;
			}
			return num;
		}
		
		/**
		 * 
		 * @param	colorStr format data #000000, 0x000000, 000000
		 * @return color in format 0x000000
		 */
		public static function getHexColor(colorStr:String):String
		{
			var r:RegExp=new RegExp(/#/g);
			var color:String = String(colorStr).replace(r, "0x");
			if (color.length < 8)
			{
				color = "0x" + color;
			}
			return color;
		}
		
	}

}